<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
			<script src="js/vue.js"></script>
	</head>
	<body>
		<div id="app">
			<button @click="sub()">-</button>{{num}}<button  @click="add()">+</button>
		</div>
	</body>
	<script>
	var app=new Vue({
		el:"#app",
		data:{
			num:1
		},
		methods:{
			add:function(){
				if(this.num<10){
					this.num++
				}else{
					alert("商品数量限购10件！")
				}
				
			},
			sub:function(){
				if(this.num>0){
					this.num--
				}else{
					alert("商品数量最少添加1件！")
				}
				
			}
		}
	})
	
	</script>
</html>
